﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Media;
//using System.Threading;

namespace WindowsFormsApplication5
{
    public class MMedia
    {
          private  string dir = " ";
          private string fulldir = " ";
          private string fulldir1 = " ";
          PictureBox temppic;
          private Data data;
          private SoundPlayer sp;

       public MMedia(string dir)  
       {

           this.dir = dir;
           fulldir = Path.Combine(dir, "16.gif");
           data = new Data();
           sp = new SoundPlayer();
           temppic = new PictureBox();
           
       }

        public void Fire(Control picturebox, System.Windows.Forms.Timer timer, Rectangle tank)
        {

            fulldir1 = Path.Combine(dir, "shot.wav");
            sp.SoundLocation = fulldir1;
            sp.Play();

           
        }
        public void Show(Control picturebox, System.Windows.Forms.Timer timer, Rectangle tank)
        {
            temppic.Size = new Size(data.tank_width, data.tank_height);
            temppic.Location = new Point(tank.Location.X, tank.Location.Y);
            temppic.SizeMode = PictureBoxSizeMode.StretchImage;
            temppic.Image = Image.FromFile(fulldir);
            picturebox.Controls.Add(temppic);
            fulldir1 = Path.Combine(dir, "032.wav");
            sp.SoundLocation = fulldir1;
            sp.Play();
            timer.Start();
            
        }

        public void Delete()
        {
            temppic.Dispose();
        }
       
    }
}
